import java.io.*;
import java.util.Scanner;

public class Demo2 {
    public static void main1(String[] args) throws IOException {
        InputStream inputStream = new FileInputStream("D:/Test/test.txt");
        byte[] b = new byte[15];
        inputStream.read(b);
        for(int i = 0; i < b.length; i+=3){
            String s = new String(b, i, 3, "UTF-8");
            System.out.print(s);
        }
    }

    //利用scanner去文件中获取数据到内存
    public static void main2(String[] args) throws FileNotFoundException {
        InputStream inputStream = new FileInputStream("D:/Test/test.txt");
        Scanner scanner = new Scanner(inputStream, "UTF-8");
        while(scanner.hasNext()){
            String s = scanner.next();
            System.out.println(s);
        }
    }

    public static void main(String[] args) throws IOException {
        OutputStream outputStream = new FileOutputStream("D:/Test/test.txt");
        outputStream.write('h');
        outputStream.write('e');
        outputStream.write('l');
        outputStream.write('l');
        outputStream.write('o');
    }
}
